package view.Items;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

public class ReviewItemGUI {

	protected int rate = 5;
	protected int i;

	public ReviewItemGUI(String leftTag, String rightTag, int x, int y, Composite gr, final Display mainDisp) {
		final Color clrWhite = new Color(mainDisp, 255, 255, 255);
		Composite cReviewRow = new Composite(gr, 0);
		cReviewRow.setBounds(x, y, 525, 50);

		// bad tag
		Label lblLeftTag = new Label(cReviewRow, SWT.CENTER);
		lblLeftTag.setText(leftTag);
		lblLeftTag.setBounds(0, 10, 100, 20);
		lblLeftTag.setForeground(clrWhite);

		for (i = 0; i <= 10; i++) {
			Label lblnumbers = new Label(cReviewRow, SWT.CENTER);
			lblnumbers.setText(String.valueOf(i));
			lblnumbers.setBounds(108 + 25 * i, 0, 20, 20);
			lblnumbers.setForeground(clrWhite);

			final Button b = new Button(cReviewRow, SWT.RADIO);
			b.setBounds(110 + 25 * i, 20, 20, 20);

			if (i == 5)
				b.setSelection(true);
			b.addSelectionListener(new SelectionAdapter() {

				@Override
				public void widgetSelected(SelectionEvent e) {
					setRate((b.getLocation().x - 110) / 25);
				}
			});
		}

		// good tag
		Label lblRightTag = new Label(cReviewRow, SWT.CENTER);
		lblRightTag.setText(rightTag);
		lblRightTag.setBounds(390, 10, 100, 20);
		lblRightTag.setForeground(clrWhite);

	}

	public int getRate() {
		return rate;
	}

	public void setRate(int rate) {
		this.rate = rate;
	}

}
